package websocket

import (
	"errors"
	"strings"
	"fmt"
)

type ConnContext struct {
	specialKey  string
	supportGzip string
}

func HashKeyAsCtx(hashKey string) (*ConnContext, error) {
	values := strings.Split(hashKey, ":")
	if (len(values) != 2) {
		return nil, errors.New("艾玛 key不对: " + hashKey)
	} else {
		return &ConnContext{values[0], values[1]}, nil
	}
}
func (ctx *ConnContext) AsHashKey() string {
	return strings.Join([]string{ctx.specialKey, ctx.supportGzip}, ":")
}
func (ctx *ConnContext) String() string {
	return fmt.Sprintf(`%s:%s`, ctx.specialKey, ctx.supportGzip)
}
